package com.qf.service.impl;

/*
 *  @author Administrator
 *  @version V1.0
 *  @Project smartdeviceplatgorm
 *  @Package com.qf.service
 *  @Description
 *  @Date2022/3/22 0022 23:36
 */

import com.qf.bean.SysMenu;
import com.qf.mapper.SysMenuMapper;
import com.qf.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@Transactional
public class SysMenuServiceImpl implements SysMenuService {


    private SysMenuMapper sysMenuMapper;

    @Autowired
    public void setSysMenuMapper(SysMenuMapper sysMenuMapper) {
        this.sysMenuMapper = sysMenuMapper;
    }



    @Override
    public List<SysMenu> findAllMenu() {
        return sysMenuMapper.findAllMenu();
    }


    @Override
    public List<SysMenu> findAllLeftMenu() {
        List<SysMenu> allMenu = findAllMenu();
        List<SysMenu> menuList = allMenu.stream().filter(sysMenu -> {
            return sysMenu.getMenuType().equalsIgnoreCase("M")&&!"#".equalsIgnoreCase(sysMenu.getUrl());
        }).collect(Collectors.toList());
        return menuList;
    }
}
